﻿using Magicodes.ExporterAndImporter.Excel.AspNetCore;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NP.BPMReportPlatform.AuthorizationProcessesManager;
using NP.BPMReportPlatform.AuthorizationProcessesManager.Dtos;
using NP.BPMReportPlatform.AuthorizationUserManager.Dtos;
using NP.BPMReportPlatform.RecurringJobs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;

namespace NP.BPMReportPlatform.AuthorizationUserManager
{
    [Authorize]
    [ApiController]
    [Route("api/AuthorizationUser")]
    public class AuthorizationUserController : BPMReportPlatformController
    {
        private readonly IUserAppService _userAppService;

        public AuthorizationUserController(IUserAppService userAppService)
        {
            _userAppService = userAppService;
        }

        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        [Route("GetUserList")]
        public async Task<PagedResultDto<UserInfoOutput>> GetUserList([FromQuery] UserInfoInput input)
        {
            return await _userAppService.GetUserList(input);
        }
        /// <summary>
        /// 导出流程信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("ExportUserList")]
        public async Task<XlsxFileResult<UserInfoOutput>> ExportUserList([FromBody] UserInfoInput input)
        {
            var rst = await _userAppService.ExportUserList(input);
            return new XlsxFileResult<UserInfoOutput>(rst, "导出Excel");
        }

        /// <summary>
        /// 编辑外部用户
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("EditOuterUser")]
        public async Task EditOuterUserAsync([FromBody] EditOuterUserInfo input)
        {
            await _userAppService.EditOuterUserAsync(input);
        }

        /// <summary>
        /// 删除审批配置
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        [Route("DeleteOuterUser")]
        public async Task DeleteOuterUserAsync([FromQuery] Guid id)
        {
            await _userAppService.DeleteOuterUserAsync(id);
        }
    }
}
